package jmu.cze.service.impl;

import jmu.cze.mapper.QueryMapper;
import jmu.cze.pojo.City;
import jmu.cze.vo.QueryResult;
import jmu.cze.service.QueryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class QueryServiceImpl implements QueryService {
    QueryMapper queryMapper;

    @Resource(name = "queryMapper")
    public void setQueryMapper(QueryMapper queryMapper) {
        this.queryMapper = queryMapper;
    }

    @Override
    public List<QueryResult> queryByCity(String start, String end, Date date) {
//        List<Integer> starts = queryMapper.getTerminalID(start);
//        List<Integer> ends = queryMapper.getTerminalID(end);
//        List<QueryResult> results = new ArrayList<QueryResult>();
//        for (Integer s : starts) {
//            for (Integer e : ends) {
//                System.out.println(s+"==>"+e);
//                results.addAll(queryMapper.queryByTerminal(s,e,date));
//            }
//        }
        return queryMapper.queryByCity(start,end,date);
    }

    @Override
    public List<QueryResult> queryByFlightNo(String flightNo, Date date) {
        return queryMapper.queryByFlightNo(flightNo, date);
    }

    @Override
    public List<City> selectAllCity() {
        return queryMapper.selectAllCity();
    }
}
